<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	$(function() {
		parent.$.messager.progress('close');

		$('#form').form({
			url : '/buildingManager/add',
			onSubmit : function() {
				parent.$.messager.progress({
					title : '提示',
					text : '数据处理中，请稍后....'
				});
				var isValid = $(this).form('validate');
				if (!isValid) {
					parent.$.messager.progress('close');
				}
				return isValid;
			},
			success : function(result) {
				parent.$.messager.progress('close');
				try{
					result = $.parseJSON(result);
					if (result.success) {
						parent.$.modalDialog.openner_datagrid.datagrid('reload');
						parent.$.modalDialog.handler.dialog('close');
					}  else {
						parent.$.messager.alert("提示",result.msg,"info");
					}
				} catch(e){
					parent.$.messager.alert("提示",result,"info");
				}
			}
		});
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="overflow: hidden;">
		<form id="form" method="post">
			<table class="table table-hover table-condensed">
			<c:choose>
				<c:when test="${isAdmin}">
					<tr>
						<th>当前小区</th>
						<td>
							<select  name="residenceId"  type="text" placeholder="小区名字"  class="easyui-combobox"  data-options="required:true,width:380,icons:[{
											iconCls:'icon-clear',
											handler: function(e){
												$(e.data.target).combobox('setValue','');
											}
										}]" >
									<c:forEach items="${residentces }" var="r">
											<option value="${r.id }">${r.name}</option>
									</c:forEach>
							</select>
						</td>
					</tr>
				</c:when>
				<c:otherwise>
				<tr>
					<th>当前小区</th>
					<td>
					<input name="residenceId" type="hidden" class="span2" value="${residence.id }" readonly="readonly"/>
					${residence.name }
					</td>
				</tr>
				</c:otherwise>
			</c:choose>
				<tr>
					<th>楼栋名称</th>
					<td>
					<input name="name" style="width:380px;" type="text" placeholder="楼栋名称" class="easyui-validatebox span2" data-options="required:true" value="">
					</td>
				</tr>
				<tr>
					<th>排序</th>
					<td>
					<input class="easyui-slider"  name="sortWeight" style="width:380px" data-options="min:1,max:100,showTip:true">
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>